
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:smart_freezer/core/utils/local_storage.dart';
import 'package:smart_freezer/ui.pages/home/device/device_detail.dart';
import 'package:smart_freezer/ui.pages/home/device/device_info.dart';
import 'package:smart_freezer/ui.pages/home/device/device_setting.dart';
import 'package:smart_freezer/ui.pages/home/device/device_setting_params.dart';
import 'package:smart_freezer/ui.pages/home/device/share/device_share.dart';
import 'package:smart_freezer/ui.pages/home/device/share/device_share_list.dart';
import 'package:smart_freezer/ui.pages/home/device/wifi_page.dart';
import 'package:smart_freezer/ui.pages/home/home_add_device.dart';
import 'package:smart_freezer/ui.pages/home/home_page.dart';
import 'package:smart_freezer/ui.pages/home/qrcode/barcode_scanner_controller.dart';
import 'package:smart_freezer/ui.pages/home/setting/setting_page.dart';
import 'package:smart_freezer/ui.pages/home/setting/settinge_choose_device.dart';
import 'package:smart_freezer/ui.pages/home/setting/settinge_collect_device.dart';
import 'package:smart_freezer/ui.pages/home/setting/settinge_language.dart';
import 'package:smart_freezer/ui.pages/home/setting/settinge_model.dart';
import 'package:smart_freezer/ui.pages/home/warninfo/home_warn_info.dart';
import 'package:smart_freezer/ui.pages/login/login_page.dart';
import 'package:smart_freezer/ui.pages/login/login_register_page.dart';
import 'package:smart_freezer/ui.pages/login/login_resetpwd_page.dart';

class LCRouter {
  static String root = "/";
  static String main = "/main-view";
  static String login = "/login-view";
  static String home = "/home-view";

  static String login_register = "/login_register-view";
  static String login_forget = "/login_forget-view";

  static String qrcode = "/qrcode-view";

  static String home_add_device = "/home_add_device-view";
  static String home_warn_info = "/home_warn_info-view";
  static String home_setting = "/home_setting-view";
  static String setting_choose_device = "/setting_choose_device-view";
  static String setting_collect_device = "/setting_collect_device-view";
  static String setting_language = "/setting_language-view";
  static String setting_model = "/setting_model-view";
  static String device_detail = "/device_detail-view";
  static String device_info = "/device_info-view";
  static String device_setting = "/device_setting-view";
  static String device_setting_params = "/device_setting_params-view";
  static String device_share_share = "/device_share_share-view";
  static String device_share_list = "device_share_list-view";


  static String wifi_page = "/wifi_page-view";

  // 每次都需要重新登录
  static final String initialRoute = LocalStorage.getIsLogin() ? home : login;

  static final List<GetPage> routes = [
    // GetPage(name: root, page: () => DisclosePage()),
    // GetPage(name: main, page: () => MainPage()),

    GetPage(name: login, page: () => LoginPage()),
    GetPage(name: login_register, page: () => LoginRegisterPage()),
    GetPage(name: login_forget, page: () => LoginResetPwdPage()),
    GetPage(name: home, page: () => HomePage()),

    GetPage(name: qrcode, page: () => BarcodeScannerWithController()),
    GetPage(name: home_add_device, page: () => HomeAddDevice()),
    GetPage(name: home_warn_info, page: () => HomeWarnInfo()),
    GetPage(name: home_setting, page: () => SettingPage()),
    GetPage(name: setting_choose_device, page: () => SettingChooseDevice()),
    GetPage(name: setting_collect_device, page: () => SettingCollectDevice()),
    GetPage(name: setting_language, page: () => SettingLanguage()),
    GetPage(name: setting_model, page: () => SettingModel()),
    GetPage(name: device_detail, page: () => DeviceDetail()),
    GetPage(name: device_info, page: () => DeviceInfo()),
    GetPage(name: device_setting, page: () => DeviceSetting()),
    GetPage(name: device_setting_params, page: () => DeviceSettingParams()),
    GetPage(name: wifi_page, page: () => LCWIFIPage()),
    GetPage(name: device_share_share, page: () => DeviceShare()),
    GetPage(name: device_share_list, page: () => DeviceShareList()),
  ];

  // 无动画跳转
  static toNamedNoAnimated(String name, {dynamic arguments}) {
    final targetPage = routes.lastWhere((element) => element.name == name);
    Get.to(targetPage.page, duration: const Duration(seconds: 0), arguments: arguments);
  }

  static offNoAnimated(String name, {dynamic arguments}) {
    final targetPage = routes.lastWhere((element) => element.name == name);
    Get.off(targetPage.page, duration: const Duration(seconds: 0), arguments: arguments);
  }

}